import request from '@/utils/request'
// 获取资源信息
function getResourcePages (data) {
  return request({
    method: 'POST',
    url: '/boss/resource/getResourcePages',
    data
  })
}
// 获取资源分类
function getResourceCategory () {
  return request({
    method: 'GET',
    url: '/boss/resource/category/getAll'
  })
}

// 保存或更新资源
function getResourceSave (data) {
  return request({
    method: 'POST',
    url: '/boss/resource/saveOrUpdate',
    data
  })
}

// 删除资源
function getResourceDel (id) {
  return request({
    method: 'DELETE',
    url: `/boss/resource/${id}`
  })
}

// 保存或更新资源分类
function categoryUpdate (data) {
  return request({
    method: 'POST',
    url: '/boss/resource/category/saveOrderUpdate',
    data
  })
}

// 删除资源分类
function categoryDel (id) {
  return request({
    method: 'DELETE',
    url: `/boss/resource/category/${id}`
  })
}

// 获取角色拥有的资源列表
function getRoleResources (roleId) {
  return request({
    method: 'GET',
    url: '/boss/resource/getRoleResources',
    params: roleId
  })
}

// 给角色分配资源
function allocateRoleResources (data) {
  return request({
    method: 'POST',
    url: '/boss/resource/allocateRoleResources',
    data
  })
}

export {
  getResourcePages,
  getResourceCategory,
  getResourceSave,
  getResourceDel,
  categoryUpdate,
  categoryDel,
  getRoleResources,
  allocateRoleResources
}
